<!DOCTYPE html>
<head>
 <title>王者荣耀</title>
 <meta charset="UTF-8">
 <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"/>
</head>
<style type="text/css">
@media screen and (min-width: 320px) and (max-width: 375px){html{font-size: 12px}}
@media screen and (max-width: 320px){html{font-size: 10px}}

 * {
  margin:0;
  padding:0;
}
.main{
 width: 100%;
 margin:0 auto;
 background: #f2f2f2;
}
#wrap {
  position:relative;
  margin:0 auto;
  width:100%;
  height:15.625rem;
}
#wrap .banner {
  position:absolute;
  top:0;
  width:100%;
  height:100%;
  opacity:0;
  transition: opacity 2s;
}
#wrap .banner .banner-img img{
 width: 100%;
 height: 15.625rem;
}
#wrap .tab{
  position:absolute;
  bottom:.5rem;
  right:.5rem;
}
    #wrap .tab span{
      display: inline-block;
      width:.5rem;
      height:.5rem;
      margin:.5rem;
      background:rgba(105,105,105,0.5);
      border-radius:50%;
      cursor: pointer;
      border:2px solid #887B6E;
    }
    #wrap .tab span.on{
      background:#E2CEB7;
    }
    #wrap .tab span:hover{
      background:#E2CEB7;
    }


.schedule,
.activity,
.information{
 width: 100%;
 /*height: 18rem;*/
 background: #fff;
 margin-top: 1rem;
 padding-top: 1rem;
}
.activity{
  padding-bottom: 1rem;
}
.schedule_title,
.activity_title,
.information_title{
 width: 16rem;
 height: 2.9rem;
 margin:0 auto;
 margin-bottom: 30px;
 background: url(../images/bg_home_title.png) no-repeat;
 background-size: 100% 100%;
 text-align: center;
 line-height: 2.9rem;
 color: #333;
 font-size: 1.5em;
}
.schedule_main{
  width: 100%;
  height: 12rem;
  /*background: red;*/
  overflow: scroll;
}
.schedule_main_ul{
  width: 44rem;
  height: 12rem;
  overflow: scroll;
}
::-webkit-scrollbar{
  display:none;
}
.schedule_main_li{
  width: 12rem;
  height: 12rem;
  list-style: none;
  float: left;
  margin-right: 1.4rem;
}
.schedule_main_li:first-child{
  margin-left: 2rem;

}
.schedule_img{
  width: 12rem;
  height: 8.3rem;
}
.game_name{
  display: inline-block;
  width: 49%;
  text-align: right;
  color: #333;
  font-size: 1rem;
}
.Online{
  display: inline-block;
  width: 48%;
  text-align: left;
  color: #333;
  font-size: 1rem;
}
.number,
.number1,
.number2{
  width: 12rem;
  text-align: center;
  color: #EB4545;
  font-size: 1rem;
}
.more{
  float: right;
  margin-right: 2.2rem;
  margin-top: -5rem;
  font-size: 1.4em;
  color: #333;
}
.more_img{
  width: 0.5rem;
  height: .7rem;
  float: right;
  margin-right: 1.2rem;
  margin-top: -4.4rem;
  color: #333;
}
.activity_ul{
  width: 92%;
  height: 15rem;
  margin:auto;
  background: url(../images/bg_home_message.png);
  background-size: 100% 100%;
  box-shadow: border-box;
  /*margin-bottom: 20px;*/
}
.activity_li{
  list-style: none;
  width: 100%;
  margin: auto;
  height: 3rem;
  line-height: 3rem;
  color: #333;
  overflow: hidden;
  white-space:nowrap; 
  text-overflow: ellipsis;
  font-size: 1.3em;
  border-bottom: 1px solid #e2e2e2;
  position: relative;
}
.activity_li:last-child{
  border:none;
}
.activity_li:before{
  content: "";
  display: block;
  width: .4rem;
  height: .4rem;
  background: #96C1FF;
  position: absolute;
  top: 1.3rem;
  left: .6rem;
}
.activity_p{
  width: 90%;
  margin: auto;
  height: 3rem;
  line-height: 3rem;
  color: #333;
  overflow: hidden;
  white-space:nowrap; 
  text-overflow: ellipsis;
  border-bottom: 1px solid #e2e2e2;
  position: relative;
}
.information_ul{
  width: 100%;
}
.information_li{
  list-style: none;
  width: 90%;
  border-bottom: 1px solid #eee;
  margin:auto;
  margin-top: 1rem;
}
.information_img{
  float: left;
  margin-right: 1rem;
  margin-bottom: 1rem;
  width:6rem;
  height: 6rem;
}
.information_li_title{
  color: #333;
  font-size: 1.1em;
  font-weight: 600;
  text-overflow: -o-ellipsis-lastline;  
  overflow: hidden;  
  text-overflow: ellipsis;  
  display: -webkit-box;  
  -webkit-line-clamp: 2;  
  -webkit-box-orient: vertical;
}
.information_li_content{
  color: #333;
  font-size: 1em;
  text-align: right;
  margin-top: 2rem;
  margin-bottom: 2rem;
}
.footers{
  width: 100%;
  height: 2.4rem;
  margin-top: 1rem;
  background: #f2f2f2;
  color: #999;
  font-size: 1em;
  text-align: center;
}
@media screen and (min-width: 376px) and (max-width: 414px){
  html{font-size: 14px}
  .more{
    margin-top: -4.4rem;
  }
  .more_img{
    margin-top: -3.8rem;
  }
}
@media screen and (min-width: 750px){
  html{font-size: 20px}
  .main{
   width: 750px;
   margin:0 auto;
   background: #f2f2f2;
  }
  .more{
  margin-top: -4.2rem;
  }
  .more_img{
  margin-top: -3.4rem;
}
.footers{
  width: 750px;
  }
}
</style>
<body>
 <div class="main">
       <div id="wrap">
      <div class="banner">
          <div class="banner-img">
              <img src="../images/1.png" width="1226" height="460" alt="轮播图1">
          </div>
      </div>

      <div class="banner">
          <div class="banner-img">
              <img src="../images/2.png" width="1226" height="460" alt="轮播图2">
          </div>
      </div>

      <div class="banner">
          <div class="banner-img">
              <img src="../images/3.png" width="1226" height="460" alt="轮播图3">
          </div>
      </div>

      <div class="banner">
          <div class="banner-img">
              <img src="../images/4.png" width="1226" height="460" alt="轮播图4">
          </div>
      </div>

      <div class="banner">
          <div class="banner-img">
              <img src="../images/5.png" width="1226" height="460" alt="轮播图5">
          </div>
      </div>

      <div class="tab">
          <span></span>
          <span></span>
          <span></span>
          <span></span>
          <span></span>
      </div>

      </div>

      <div class="schedule">
       <p class="schedule_title">赛程数据</p>
       <div class="schedule_main">
         <ul class="schedule_main_ul">
           <li class="schedule_main_li" id="0">
             <img src="../images/image_home_wz.png" class="schedule_img">
             <span class="game_name">王者荣耀</span>
             <span class="Online">在线人数</span>
             <p class="number"></p>
           </li>

           <li class="schedule_main_li" id="1">
             <img src="../images/image_home_hy.png" class="schedule_img">
             <span class="game_name">荒野行动</span>
             <span class="Online">在线人数</span>
             <p class="number1"></p>
           </li>

           <li class="schedule_main_li" id="2">
             <img src="../images/image_home_yx.png" class="schedule_img">
             <span class="game_name">英雄联盟</span>
             <span class="Online">在线人数</span>
             <p class="number2"></p>
           </li>
         </ul>
       </div>
      </div>

      <div class="activity">
       <p class="activity_title">活动公告</p>
       <a href="activityMore.html">  
         <span class="more">更多</span>
         <img src="../images/icon_home_more.png" class="more_img">
       </a>
       <ul class="activity_ul">
         
       </ul>
      </div>
      

      <div class="information">
       <p class="information_title">新闻资讯</p>
       <div>  
         <a href="MoreInformation.html"><span class="more">更多</span></a>
         <img src="../images/icon_home_more.png" class="more_img">
         <ul class="information_ul">
           
         </ul>
       </div>
      </div>

      <div class="footers">
        更多资讯 敬请期待
      </div>
</div>
<script src="../js/public.js"></script>
<script src="../js/jquery-3.2.1.min.js"></script>
<script type="text/javascript">

 var oBody = document.getElementsByTagName("body")[0];
 var aBanner = document.getElementsByClassName("banner");
 var aSpan = document.getElementsByClassName("tab")[0].getElementsByTagName("span");
 var Oon = document.getElementsByClassName("on")[0];
 aBanner[0].style.opacity = "1";
 aSpan[0].className = "on";
 var num = 0;

 for(var i = 0;i < aSpan.length;i++){
 aSpan[i].index = i;
 aSpan[i].onclick = function(){  //点击小圆点图片相对应的进行切换
 for(var j = 0 ;j < aSpan.length; j++){
   num = this.index;
   aSpan[j].className = "";
   aBanner[j].style.opacity = "0";
 }
 aSpan[num].className = "on";
 aBanner[num].style.opacity = "1";
 }
 }

 function Time(){/*设置定时器运行的函数*/
num++;
if(num < 5){
    for(var j = 0 ;j < aSpan.length; j++){
    aSpan[j].className = "";
    aBanner[j].style.opacity = "0";
}
aSpan[num].className = "on";
aBanner[num].style.opacity = "1";
}else {
    num = -1;
}         
}
clearInterval(timer);
var timer = setInterval("Time()",2000);/*调用定时器*/

oBody.onmouseover = function(){/*鼠标引入，清除定时器，轮播图停止*/
    clearInterval(timer);
};
oBody.onmouseout = function(){/*鼠标移出，重新调用定时器，轮播图开始*/
    clearInterval(timer);
     timer = setInterval("Time()",2000);
};


//在线人数
    $('.schedule_main_li').click(function(){
      window.location.href='online.html?id='+this.id;
    })

    function activityclick(){
      $(".activity_ul").on("click","li", function() {
              // console.log(this.id)
              window.location.href = 'Moreactivity1.html?fdId='+this.id;
             })
    }

    function informationclick(){
      $(".information_ul").on("click","li", function() {
              // console.log(this.id)
              window.location.href = 'MoreInformation2.html?fdId='+this.id;
             })
    }

   $(function () {

 $.post(systemNotice, {
            type: 1
        }, (res) => {
            let obj = res.obj;
            obj.forEach((item, index) => {
                let homeStm = ` <li class="activity_li" onclick="activityclick()" id="${item.fdId}"><p class="activity_p">${item.fdTitle}</p</div>`
                if (index < 5) {
                    $('.activity_ul').append(homeStm)
                }
            });
        });

 $.post(systemNotice, {
            type: 2
        }, (res) => {
          // console.log(res)
            let obj = res.obj;
            obj.forEach((item, index) => {
              // console.log(item.fdBgPic)
              let url=urlHead+item.fdBgPic;
                let homeStm = ` <li class="information_li" onclick="informationclick()" id="${item.fdId}">
             <img src="${url}" class="information_img">
             <div>
               <p class="information_li_title" >${item.fdTitle}</p>
               <p class="information_li_content">${item.fdCreatedTime}</p>
             </div>
           </li>`
                if (index < 5) {
                    $('.information_ul').append(homeStm)
                }
            });
        });
})

//王者荣耀
$(function () {
        initSocket();
        var outButton;

        function initSocket(){
          var timestamp1 =new Date().getTime();
          // console.log(timestamp1);
            webSocket = new WebSocket('ws://192.168.1.88:8080/gamingDataForKing?flag=timestamp1');
            outButton=document.getElementsByClassName('number');
            webSocket.onerror = function (event) {
                  onError(event);
              };
              webSocket.onopen = function (event) {
                  onOpen(event);
              };
              webSocket.onmessage = function (event) {
                  onMessage(event);

              };
        }
        function onError(event){

        }
        function onOpen(event){
        }
        function onMessage(event){
          // console.log(event)
              var m=event.data.split(":")[3].split('"')[1];
              writeToScreen(m);
        }
        function writeToScreen(message) { 
          // console.log(outButton)
            outButton[0].innerHTML=message;
        }
        })

//荒野行动
        $(function () {
            initSocket();
        var outButton1;

        function initSocket(){
          var timestamp1 =new Date().getTime();
          // console.log(timestamp1);
            webSocket = new WebSocket('ws://192.168.1.88:8080/gamingDataForHero?flag=timestamp1');
            outButton1=document.getElementsByClassName('number1');
            webSocket.onerror = function (event) {
                  onError(event);
              };
              webSocket.onopen = function (event) {
                  onOpen(event);
              };
              webSocket.onmessage = function (event) {
                  onMessage(event);

              };
        }
        function onError(event){

        }
        function onOpen(event){
        }
        function onMessage(event){
          // console.log(event)
              var m=event.data.split(":")[3].split('"')[1];
              writeToScreen(m);
        }
        function writeToScreen(message) { 
          console.log(outButton1)
            outButton1[0].innerHTML=message;
        }
        })

//英雄联盟
        $(function () {
            initSocket();
        var outButton2;

        function initSocket(){
          var timestamp2 =new Date().getTime();
          // console.log(timestamp2);
            webSocket = new WebSocket('ws://192.168.1.88:8080/gamingData?flag=timestamp2');
            outButton2=document.getElementsByClassName('number2');
            webSocket.onerror = function (event) {
                  onError(event);
              };
              webSocket.onopen = function (event) {
                  onOpen(event);
              };
              webSocket.onmessage = function (event) {
                  onMessage(event);

              };
        }
        function onError(event){

        }
        function onOpen(event){
        }
        function onMessage(event){
          // console.log(event)
              var m=event.data.split(":")[3].split('"')[1];
              writeToScreen(m);
        }
        function writeToScreen(message) { 
          // console.log(outButton2)
            outButton2[0].innerHTML=message;
        }
        })

</script>
</body>
</html>